import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TheSecondTask {
	
	private static final String INPUT = "http://some_domain/path/?key1=value1&key2=value2&key3=value3"; 
	private static final String REGULAR = "(^http://)|(\\/\\?)|(\\/)|(\\&)";
	private final Pattern p = Pattern.compile("\\w\\=\\w");
	private static boolean ifMatch;
	
	public static void main(String[] args) {
		TheSecondTask stask = new TheSecondTask();
		
		String queryString = new String(INPUT);

		String[] params = queryString.split(REGULAR);

		for (String param : params) {
			ifMatch = true;
			if(!param.equals("")) {
				stask.getMatchOfQuery(param);
				if(ifMatch)
					System.out.println(param);
			}
		}
		System.out.println("The following " + INPUT + " URI was parsed");
	}
	
	private void getMatchOfQuery(String param) {
		Matcher m = p.matcher(param);
		while(m.find()) {
			System.out.println(setQuery(param));
			ifMatch = false;
		}
	}
	
	private Map<String, String> setQuery(String param) {
		Map<String, String> map = new HashMap<String, String>();
		String[] parse = param.split("=");
		map.put(parse[0], parse[1]);
		
		return map;
	}

}
